package config

import (
	"blockchain_data/middleware"
	"blockchain_data/utils"
	"github.com/sirupsen/logrus"
	"gopkg.in/ini.v1"
)

var log *logrus.Logger
var(
	AppModel string
	HttpPort string
	Bourses string

	OkexGoodsList string
	OkexServerList string
	OkexWsPublicHost string
	OkexWsPrivateHost string
	OkexApiHost string
	OkexTestWsPublicHost string
	OkexTestWsPrivateHost string
	OkexTestApiHost string
	OkexTimeoutSecond int
	OkexTimedFundingRate string

	RedisHost string
	RedisPassWord string



)
func init()  {
	log = middleware.DataLogger()
	file,err := ini.Load(utils.GetCurrentPath() +"/config/config.ini")
	if err != nil {
		log.Error("配置文件读取错误，请检查文件路径：",err)
	}
	LoadServer(file)
}
func LoadServer(file *ini.File)  {
	AppModel = file.Section("server").Key("AppModel").MustString("debug")
	HttpPort = file.Section("server").Key("HttpPort").MustString(":8885")
	Bourses = file.Section("server").Key("Bourses").MustString("")

	// okex
	OkexGoodsList = file.Section("server").Key("OkexGoodsList").MustString("uswap,bswap,jswap")
	OkexServerList = file.Section("server").Key("OkexServerList").MustString("tick")
	OkexWsPublicHost = file.Section("server").Key("OkexWsPublicHost").MustString("ws.okex.com:8443/ws/v5/public")
	OkexWsPrivateHost = file.Section("server").Key("OkexWsPrivateHost").MustString("ws.okex.com:8443/ws/v5/private")
	OkexApiHost = file.Section("server").Key("OkexApiHost").MustString("www.okex.com")
	OkexTestWsPublicHost = file.Section("server").Key("OkexTestWsPublicHost").MustString("wspap.okex.com:8443/ws/v5/public?brokerId=9999")
	OkexTestWsPrivateHost = file.Section("server").Key("OkexTestWsPrivateHost").MustString("wspap.okex.com:8443/ws/v5/private?brokerId=9999")
	OkexTestApiHost = file.Section("server").Key("OkexTestApiHost").MustString("www.okex.com")
	OkexTimeoutSecond = file.Section("server").Key("OkexTimeoutSecond").MustInt(45)
	OkexTimedFundingRate = file.Section("server").Key("OkexTimedFundingRate").MustString(" 15 0,8,16 * * *")

	RedisHost = file.Section("database").Key("RedisHost").MustString("localhost:6379")
	RedisPassWord = file.Section("database").Key("RedisPassWord").MustString("1234")


}
